//
//  TitleImageControlView.m
//  sensen_ios
//
//  Created by mc on 16/2/23.
//  Copyright © 2016年 pro. All rights reserved.
//

#import "TitleImageControlView.h"

//用于显示待付款订单的个数
#import "NoticeView.h"



@implementation TitleImageControlView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (instancetype)initWithFrame:(CGRect)frame
                        Image:(NSString *)image
                        Title:(NSString *)title
                        count:(int)count{
    self = [super initWithFrame:frame];
    if (self) {
        self.userInteractionEnabled = YES;
        
        CGFloat height =  44;
        // 创建子视图
        self.imageView = [[UIImageView alloc] init];
        [self addSubview:self.imageView];
        [self.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.mas_top).offset(10);
            make.centerX.equalTo(self.mas_centerX);
            make.size.mas_equalTo(CGSizeMake(height * 0.6, height * 0.6));
        }];
        self.imageView.image = [UIImage imageNamed:image];
        
        //标题
        self.titleLabel = [[UILabel alloc] init];
        [self addSubview:self.titleLabel];
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
             make.centerX.equalTo(self.mas_centerX);
             make.size.mas_equalTo(CGSizeMake(height * 1.5, 13));
             make.bottom.equalTo(self.mas_bottom).offset(-10);
        }];
        self.titleLabel.textAlignment = NSTextAlignmentCenter;
        self.titleLabel.font = FONT(13);
        self.titleLabel.textColor = [UIColor darkGrayColor];
        self.titleLabel.text = title;
        
        
        
        //个数
        self.countView = [[NoticeView alloc] init];
        [self.imageView addSubview:self.countView];
        [self.countView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self.imageView.mas_right);
            make.top.equalTo(self.imageView.mas_top).offset(0);
            make.size.mas_equalTo(CGSizeMake(10, 10));
        }];
        self.countView.intCount = count;
        self.countView.hidden = YES;
    }
    
    return self;
    
}

@end
